<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../../_template.xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://xmlns.jcp.org/jsf/core">

    <ui:define name="centro">
        <h:form>
            <h:panelGrid columns="2">
                <p:outputLabel value="Cliente desde: " style="margin-left: 700px; margin-bottom: 20px; margin-top: 20px"/>
                <p:outputLabel value="#{clienteBean.clientePJ.clienteDesde}">
                    <f:convertDateTime pattern="dd/MM/yyyy" /> 
                </p:outputLabel>
            </h:panelGrid>
            <p:outputLabel value="Cadastro de Cliente PJ - Consultar" style="font-size: x-large; margin-left: 25px" styleClass="labelInserir" />
            <p:messages />
            <p:fieldset styleClass="fieldsetInsert" style=" margin-left: 25px">
                
                <h:panelGrid columns="2">
                    <h:panelGrid columns="1">
                        <p:outputLabel style="margin-right: 15px;" value="Nome do cliente:" for="nomeCliente" />
                        <p:inputText id="nomeCliente"  value="#{clienteBean.clientePJ.nome}" style="width: 600px;" disabled="true" />
                    </h:panelGrid>

                    <h:panelGrid columns="1" style=" margin-left: 10px;">
                        <p:outputLabel style="text-align: left" value="CNPJ:" for="cnpj"  />
                        <p:inputMask id="cnpj"  mask="99.999.999/9999-99" value="#{clienteBean.clientePJ.cnpj}" disabled="true" /> 
                    </h:panelGrid>
                </h:panelGrid>
                
                <h:panelGrid columns="1">
                    <h:panelGrid columns="1">
                        <p:outputLabel style="text-align: left;" for="nomeF" value="Nome fantasia:" />
                        <p:inputText id="nomeF"  value="#{clienteBean.clientePJ.nomeFantasia}" style="width: 600px;" disabled="true" />
                    </h:panelGrid>
                </h:panelGrid>
                
                <h:panelGrid columns="3">
                    <h:panelGrid columns="1"  >
                        <p:outputLabel style="text-align: left;" for="atvP" value="Atividade principal:" />
                        <p:selectOneMenu id="atvP" value="#{clienteBean.clientePJ.atividadePrincipal}" disabled="true"
                                         converter="entityConverter" style="width: 200px">
                            <f:selectItem itemLabel="Escolha uma opção" noSelectionOption="true" />
                            <f:selectItems value="#{atividadePrincipalBean.atividadesPrincipais}" var="atividade" itemLabel="#{atividade.descricao}"/>
                        </p:selectOneMenu>
                    </h:panelGrid>
                
                    <h:panelGrid columns="1" style=" margin-left: 10px;" > 
                        <p:outputLabel style="text-align: left;" for="dataConst" value="Data da constituição:" />
                        <p:calendar id="dataConst" pattern="dd/MM/yyyy" yearRange="c-100:c+100" navigator="true" readonlyInput="true"
                                    maxdate="#{clienteBean.dataAtual}" value="#{clienteBean.clientePJ.dataConstituicao}" disabled="true" />
                    </h:panelGrid>

                    <h:panelGrid columns="1" style=" margin-left: 10px;" >
                        <p:outputLabel style="text-align: left;" for="ise" value="Inscrição estadual:" />
                        <p:inputText id="ise"  value="#{clienteBean.clientePJ.inscricaoEstadual}" style="width: 200px" disabled="true" />
                    </h:panelGrid>

                </h:panelGrid>
                
                 <h:panelGrid columns="1">
                    <h:panelGrid columns="1" >
                        <p:outputLabel style="text-align: left" value="Endereço" for="rua" />
                        <p:inputText id="rua"  value="#{clienteBean.clientePJ.endereco.rua}" style="width: 860px;" disabled="true" />
                    </h:panelGrid>
                </h:panelGrid>
                    
                <h:panelGrid columns="3" >
                    <h:panelGrid columns="1">
                        <p:outputLabel style="text-align: left" value="Cidade" for="cidade" />
                        <p:inputText id="cidade"  value="#{clienteBean.clientePJ.endereco.cidade}" style="width: 520px" disabled="true" />
                    </h:panelGrid>

                    <h:panelGrid columns="1" style=" margin-left: 10px;" >
                        <p:outputLabel style="text-align: left" value="UF" for="estado" />
                        <p:selectOneMenu id="estado" value="#{clienteBean.clientePJ.endereco.estado}" style="width: 65px" disabled="true">
                            <f:selectItem itemLabel=" "/>
                            <f:selectItems value="#{clienteBean.unidadesFederativas}" />
                        </p:selectOneMenu>
                    </h:panelGrid>
                    
                    <h:panelGrid columns="1" style=" margin-left: 10px;" >
                        <p:outputLabel style="text-align: left; " value="CEP" for="cep" />
                        <p:inputMask id="cep" mask="99.999-999" value="#{clienteBean.clientePJ.endereco.cep}" disabled="true" />
                    </h:panelGrid>
                </h:panelGrid>

                <h:panelGrid columns="2">
                    <h:panelGrid columns="1">
                        <p:outputLabel style="text-align: left" value="Telefone 1" for="tel1" />
                        <p:inputMask id="tel1" mask="(99)9999-9999" value="#{clienteBean.clientePJ.endereco.telefone1}" disabled="true" />
                    </h:panelGrid>
                    
                    <h:panelGrid columns="1" >
                        <p:outputLabel style="text-align: left" value="Telefone 2" for="tel2" />
                        <p:inputMask id="tel2" mask="(99)9999-9999" value="#{clienteBean.clientePJ.endereco.telefone2}" disabled="true" />
                    </h:panelGrid>
                </h:panelGrid>
                <br />                
                
                <p:commandButton value="Alterar" icon="ui-icon-check" action="incluirClientePJ" style="margin-left: 5px;" ajax="false" />
                <p:commandButton value="Excluir" icon="ui-icon-trash" action="#{clienteBean.removerClientePJ(clienteBean.clientePJ)}" 
                                 update="@all" style="margin-left: 10px">
                    <p:confirm header="Confirmação" message="Deseja realmente excluir a informação?" icon="ui-icon-alert" />
                    <p:confirmDialog global="true"  showEffect="fade" >
                        <p:commandButton value="Sim" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
                        <p:commandButton value="Não" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
                    </p:confirmDialog>
                </p:commandButton>
                <p:commandButton value="Voltar" icon="ui-icon-arrowreturnthick-1-w" action="#{clienteBean.voltarParaCliente}" immediate="true"
                                 ajax="false" style="margin-left: 10px"/>
            </p:fieldset>
        </h:form>
    </ui:define>
</ui:composition>
